﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;

namespace MINERP.DAL.InfoConfig
{
    public class TechDAL:DALBase
    {
        private static ObjectQuery<tb_Tech> GetTechs()
        {
            return DataEntites.tb_Tech;
        }

        /// <summary>
        /// Get Tech list
        /// </summary>
        /// <returns></returns>
        public static List<tb_Tech> GetTechList()
        {
            List<tb_Tech> list = new List<tb_Tech>();
            foreach (tb_Tech tech in GetTechs())
            {
                list.Add(tech);
            }
            return list;
        }
        /// <summary>
        /// Get Tech object
        /// </summary>
        /// <param name="techId"></param>
        /// <returns></returns>
        public static tb_Tech GetTechObj(string techName)
        {
            return DataEntites.tb_Tech.First(t => t.TechName == techName);
        }

        /// <summary>
        /// Get Tech object
        /// </summary>
        /// <param name="techId"></param>
        /// <returns></returns>
        public static tb_Tech GetTechObj(int id)
        {
            return DataEntites.tb_Tech.First(t => t.TechId ==id);
        }
        /// <summary>
        /// add Tech
        /// </summary>
        /// <param name="obj"></param>
        public static void Add(tb_Tech obj)
        {
            DataEntites.AddTotb_Tech(obj);
            DataEntites.SaveChanges();

        }
        /// <summary>
        /// Update Tech
        /// </summary>
        public static void Update()
        {
            DataEntites.SaveChanges();
        }
        /// <summary>
        /// Delete Tech
        /// </summary>
        /// <param name="obj"></param>
        public static void Delete(tb_Tech obj)
        {
            DataEntites.DeleteObject(obj);
            DataEntites.SaveChanges();
        }

    }
}
